#pragma once

#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include "sock_tcp.hpp"
#include "error.hpp"

class ClientTCP
{
public:
    ClientTCP(const std::string &ip, const uint16_t &port)
        : _serverIp(ip), _serverPort(port)
    {
    }
    ~ClientTCP() {}

    void Init()
    {
        _sockfd.Socket();
        _sockfd.Connect(_serverIp, _serverPort);
    }

    void Start()
    {
        while (true)
        {
            std::string buf;
            std::cout << "Please Enter# ";
            std::cin >> buf;
            _sockfd.Send(buf);
            std::string recvStr = _sockfd.Recv();
            std::cout << "Server Echo# " << recvStr << std::endl;
        }
    }

private:
    SockTCP _sockfd;
    uint16_t _serverPort;
    std::string _serverIp;
};